//
//  ShellProfitCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/10/24.
//  Copyright © 2019 VV. All rights reserved.
//

#import "ShellProfitCell.h"
#import "ShellProfitModel.h"




@interface ShellProfitCell()
//背景
@property (nonatomic,strong) UIView *bgView;

//时间
@property (nonatomic,strong) UILabel *timeLabel;
//数量
@property (nonatomic,strong) UILabel *numberLabel;

//金额
@property (nonatomic,strong) UILabel *amountLab;
//收益
@property (nonatomic,strong) UILabel *profitLab;
//奖励
@property (nonatomic,strong) UILabel *rewardLab;

@end

@implementation ShellProfitCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = UIColorHex(0x04172A);
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{
    
    [self.contentView addSubview:self.bgView];
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.right.mas_equalTo(-15);
        make.height.mas_equalTo(50);
        make.top.mas_equalTo(0);
    }];
    self.bgView.cornerRadius = 4;
    
    //时间
    [self.contentView addSubview:self.timeLabel];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       make.centerY.mas_equalTo(self.contentView.mas_centerY);
       make.left.mas_equalTo(20);
       make.width.mas_equalTo(80);
       make.height.mas_equalTo(self.contentView);
    }];
       
    //数量
   [self.contentView addSubview:self.numberLabel];
   [self.numberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       make.centerY.mas_equalTo(self.contentView.mas_centerY);
       make.left.mas_equalTo(110);
       make.width.mas_equalTo(35);
       make.height.mas_equalTo(self.contentView);
   }];
    
    //金额
    [self.contentView addSubview:self.amountLab];
    [self.amountLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(150);
        make.width.mas_equalTo(60);
        make.height.mas_equalTo(self.contentView);
    }];

    
    //收益
    [self.contentView addSubview:self.profitLab];
    [self.profitLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(220);
        make.width.mas_equalTo(55);
        make.height.mas_equalTo(self.contentView);
    }];

    
      //奖励
      [self.contentView addSubview:self.rewardLab];
      [self.rewardLab mas_makeConstraints:^(MASConstraintMaker *make) {
          make.centerY.mas_equalTo(self.contentView.mas_centerY);
          make.left.mas_equalTo(285);
          make.width.mas_equalTo(K_SCREENWIDTH - 20 - 285);
          make.height.mas_equalTo(self.contentView);
      }];
}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellProfitModel *profitModel = modelObject;
    self.timeLabel.text = profitModel.settlDate;

    if(self.indexPath.row % 2 == 0){
        self.bgView.backgroundColor = UIColorHex(0x08233F);
    } else {
        self.backgroundColor = UIColorHex(0x04172A);
    }
    
    NSString *orderCount = [NSString stringWithFormat:@"%ld",(long)profitModel.orderCount];
    NSString *orderAmount = [NSString stringWithFormat:@"%f",profitModel.orderAmount].saveDecimal;
    NSString *orderProfit = [NSString stringWithFormat:@"%f",profitModel.orderProfit].saveDecimal;
    NSString *hashRateAward = [NSString stringWithFormat:@"%f",profitModel.hashRateAward].saveDecimal;

    self.numberLabel.text = orderCount;
    self.amountLab.text = orderAmount;
    self.profitLab.text = orderProfit;
    self.rewardLab.text = hashRateAward;

}


- (UIView *)bgView{
    if(!_bgView){
        _bgView = [[UIView alloc] init];
    }
    return _bgView;
}

//时间
- (UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0x678DA8) font:k_textFont(13)];
        [_timeLabel lz_centerAlignment];
    }
    return _timeLabel;
}

//数量
- (UILabel *)numberLabel{
    if(!_numberLabel){
        _numberLabel = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _numberLabel;
}

//金额
- (UILabel *)amountLab{
    if(!_amountLab){
        _amountLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _amountLab;
}

//收益
- (UILabel *)profitLab{
    if(!_profitLab){
        _profitLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _profitLab;
}

//奖励
- (UILabel *)rewardLab{
    if(!_rewardLab){
        _rewardLab = [UILabel lz_createLabWithTextColor:UIColorHex(0xFFFFFF) font:k_textFont(13)];
    }
    return _rewardLab;
}

@end
